package com.cloud.order.service.feign;

import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class FeignHystrixService implements FallbackFactory<FeignService> {
    Logger logger = LoggerFactory.getLogger(this.getClass());

    @Override
    public FeignService create(Throwable throwable) {
        return new FeignService() {
            @Override
            public String getPort() {
                logger.info("[getPort]服务器异常:{}", throwable.getMessage());
                return "[getPort]服务器异常";
            }

            @Override
            public String timeOut() {
                logger.info("[timeOut]服务器异常:{}", throwable.getMessage());
                return "[timeOut]服务器异常";
            }
        };
    }
}
